import request from '@/utils/request'

export function delGroup(group_id) {
  return request({
    url: '/group/del',
    method: 'post',
    params: {
      group_id: group_id
    }
  })
}

// update Group
export function updateGroup(group) {
  return request({
    url: '/group/update',
    method: 'post',
    params: {
      group_id: group.group_id,
      name: group.name,
      enabled: group.enabled,
      description: group.description
    }
  })
}

// update Group
export function updateStatus(group) {
  return request({
    url: '/group/update',
    method: 'post',
    params: {
      group_id: group.group_id,
      enabled: group.enabled,
      description: group.description
    }
  })
}

// create Group
export function createGroup(group) {
  return request({
    url: '/group/create',
    method: 'post',
    params: {
      name: group.name,
      enabled: group.enabled,
      description: group.description
    }
  })
}

export function getGroupList(params) {
  return request({
    url: '/group/list',
    method: 'post',
    params: {
      page: params.page,
      limit: params.limit,
      description: params.description
    }
  })
}

export function haveAuth(group_id) {
  return request({
    url: '/group/haveAuth',
    method: 'post',
    params: {
      group_id: group_id
    }
  })
}

export function saveAuthData(group_id, saveAuthData) {
  return request({
    url: '/auth/saveAuth',
    method: 'post',
    params: {
      group_id: group_id,
      rule_ids: saveAuthData
    }
  })
}
